
package com.oa.modules.sys.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.oa.modules.sys.entity.SysUserRoleEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户与角色对应关系
 *
 * @author admin
 */
@Mapper
public interface SysUserRoleDao extends BaseMapper<SysUserRoleEntity> {
	
	/**
	 * 根据用户ID，获取角色ID列表
	 */
	List<Long> queryRoleIdList(Long userId);


	/**
	 * 根据用户ID，获取角色ID列表
	 */
	@Select("<script>" +
			"select t1.user_id from sys_user_role t1 " +
			"where role_id = ${userId}" +
			"</script>")
	List<Long> queryUserIdList(@Param("roleId") Long roleId);

	/**
	 * 根据角色ID数组，批量删除
	 */
	int deleteBatch(Long[] roleIds);
}
